<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/admin/jsp/taglibs.jsp"%>
<html>
	<head>
		<%@ include file="/admin/jsp/header.jsp"%>
		<%@ include file="/framework/jsp/tablesorter.jsp"%>
	</head>
	<body onload="init();">
		<table width="98%" border="0" align="center" cellpadding="3" cellspacing="0">
			<tr>
				<td class="page-title">
					<img src="../images/page_title.gif" alt="title" width="17" height="12" align="absmiddle">
					&nbsp;&nbsp; 组织管理 » 部门管理
				</td>
			</tr>
		</table>
		<br>
		<form id="mainForm" action="/admin/jsp/deptMgr.do?method=queryDept" method="post">
			<input type="hidden" name="pageNo" id="pageNo" value="${page.pageNo}" />
			<input type="hidden" name="pageSize" id="pageSize" value="${page.pageSize}" />
			<input type="hidden" name="orderBy" id="orderBy" value="${page.orderBy}" />
			<input type="hidden" name="order" id="order" value="${page.order}" />
			<fieldset style="width: 98%; padding: 10px">
				<legend>
					单位查询
				</legend>
				<table width="60%" height="50" border="0" cellpadding="0" cellspacing="0">
					<tr>
						<td>
							单位名称：
						</td>
						<td>
							<input type="text" name="filter_LIKE_deptName" value="${param['filter_LIKE_deptName']}" size="20">
						</td>
						<td>
							单位状态：
						</td>
						<td>
							<select name="filter_EQ_status" id="status">
								<option value="">
									--全部--
								</option>
								<option value="1">
									有效
								</option>
								<option value="0">
									无效
								</option>
							</select>
						</td>
					</tr>
					<tr>
						<td align="right" colspan="4">
							<input type="button" class="short-button" value="查  询" onclick="search()"/>
						</td>
					</tr>
				</table>
			</fieldset>
			<br>
			<table width="90%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td>
						<input type="button" class="short-button" value="新  增"
							onclick="javascript:window.location='/admin/jsp/deptMgr.do?method=addDept'" />
						&nbsp;&nbsp;&nbsp;
						<input type="button" class="short-button" value="删除所选" onclick="delChecked()" />
					</td>
				</tr>
			</table>
			<table id="tableList" cellspacing="1" class="tablesorter" width="90%">
				<thead>
					<tr align="center">
						<th width="4%">
							<input class="checkbox" type="checkbox" name="operCorpId" onclick="javascript:selectAll('corpId',this.checked)">
						</th>
						<th>
							单位名称
						</th>
						<th>
							上级单位
						</th>
						<th>
							单位状态
						</th>
						<th>
							操作
						</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${page.totalCount != '0'}">
						<c:forEach var="dept" items="${page.result}" varStatus="status">
							<tr align="center">
								<td>
									<input class="checkbox" type="checkbox" name="corpId" value="<c:out value='${corp.corpId}' />" />
								</td>
								<td>
									<c:out value="${dept.deptName}"></c:out>
								</td>
								<td>
									<c:out value="${dept.parentName}"></c:out>
								</td>
								<td>
									<c:choose>
										<c:when test="${dept.status=='1'}">有效</c:when>
										<c:when test="${dept.status=='0'}">
											<font color="red">无效</font>
										</c:when>
									</c:choose>
								</td>
								<td>
									<img src="../images/modp.gif" title="修改" style="cursor: pointer" onclick=editDept('<c:out value="${dept.deptId}" />')>
									<img src="../images/delp.gif" title="删除" style="cursor: pointer" onclick=delDept('<c:out value="${dept.deptId}" />')>
								</td>
							</tr>
						</c:forEach>
					</c:if>
					<c:if test="${page.totalCount == '0'}">
						<tr align="center">
							<td colspan="7" align="left">
								暂无符合条件的记录
							</td>
						</tr>
					</c:if>
				</tbody>
			</table>
			<div>
				<jsp:include page="/framework/jsp/pager.jsp" flush="true" />
			</div>
		</form>
	</body>
	<script type="text/javascript">
	//查询	
	function search(){
		$("#order").val("desc");
		$("#orderBy").val("deptName");
		$("#pageNo").val("1");
		$("#pageSize").val("10");
		$("#mainForm").submit();
	}
	//编辑
	function editDept(deptId)
	{
		window.location="/admin/jsp/deptMgr.do?method=editDept&deptId="+deptId;
	}
	//删除
	function delDept(corpId)
	{
		if(confirm('确定删除该单位？'))
			window.location="/admin/jsp/deptMgr.do?method=delDept&deptId="+deptId;
	}
	//批量删除
	function delChecked()
	{
		if(getCheckboxCheckedValue("corpId") != "")
		{
			if(confirm('确定删除所选单位？'))
			{
				//$("#deleteForm").submit();
				document.getElementById("mainForm").action = "/admin/jsp/deptMgr.do?method=delDepts";
				document.getElementById("mainForm").submit();
			}
		}else
		{
			alert("请选择需要删除的单位!");
		}
	}
	//页面加载初始化方法，实现查询条件下拉列表的回显功能
	function init()
	{
		var status = "${param['filter_EQ_status']}";
		document.getElementById("status").value = status;
	}
	</script>
</html>